<?php if(!defined('BASEPATH')) exit("Sorry, what you're looking not found.");
class C_sertifikat extends Nvl_Controller{
    function __construct(){
        parent::__construct();
        session_start();
		$this->__checkSession();
        $this->load->model('m_sertifikat');
    }

    function index(){
        $this->load->view('pages/v_sertifikat');
    }
	
	function cetak_sertifikat(){
		$params = json_decode($this->input->post('params'));
		extract(get_object_vars($params));
		extract(get_object_vars($form_data));
		$data['records'] = $this->m_sertifikat->get_records($form_data);
		$data['records_det'] = $this->m_sertifikat->get_detail($form_data);
		
		/* $view = $this->load->view('sertifikat', $data, TRUE);
		$this->load->library('html2pdf');
		$this->html2pdf->folder('./temp/');
		$this->html2pdf->filename('galuh.pdf');
		$this->html2pdf->paper('A4', 'potrait');
		$this->html2pdf->html($view);
		if($this->html2pdf->create('save')) {
            echo 'galuh.pdf';
        } */
		
		$filename = $_SESSION[SESSION_USERID] . '.html';
		$print_view = $this->load->view('sertifikat', $data, TRUE);
		$print_file = fopen('temp/'. $filename, 'w+');
		fwrite($print_file, $print_view);
		echo $filename;
	}
}